package com.ruoyi.service.impl;

import java.util.List;

import com.ruoyi.domain.dto.PenaltyDto;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.mapper.PenaltyMapper;
import com.ruoyi.domain.Penalty;
import com.ruoyi.service.IPenaltyService;

/**
 * 罚款业务Service业务层处理
 *
 * @author qyb
 * @date 2023-12-26
 */
@Service
public class PenaltyServiceImpl implements IPenaltyService
{
    @Autowired
    private PenaltyMapper penaltyMapper;
    /**
     * 查询罚款业务
     *
     * @param penaltyId 罚款业务主键
     * @return 罚款业务
     */
    @Override
    public Penalty selectPenaltyByPenaltyId(Long penaltyId)
    {
        return penaltyMapper.selectPenaltyByPenaltyId(penaltyId);
    }
    /**
     * 模糊查询
     *
     * @param penaltyDto 罚款业务
     * @return 罚款业务集合
     */
    public List<PenaltyDto> selectSearchList(PenaltyDto penaltyDto){
        return penaltyMapper.selectSearchList(penaltyDto);
    }
    /**
     * 通过userId查看使用的角色roleId
     */
    public PenaltyDto selectRoleIdByUserId(PenaltyDto penaltyDto){
        Long user_id = SecurityUtils.getUserId();
        PenaltyDto pd=new PenaltyDto();
        pd.setUserId(user_id);
        pd=penaltyMapper.selectRoleIdByUserId(pd);
        return pd;
    }
    /**
     * 新增罚款业务
     *
     * @param penalty 罚款业务
     * @return 结果
     */
    @Override
    public int insertPenalty(Penalty penalty) {
        return penaltyMapper.insertPenalty(penalty);
    }

    /**
     * 修改罚款业务
     *
     * @param penalty 罚款业务
     * @return 结果
     */
    @Override
    public int updatePenalty(Penalty penalty) {
        Long admin_id = SecurityUtils.getUserId();
        penalty.setAdminId(admin_id);
        penalty.setUpdateTime(DateUtils.getNowDate());
        return penaltyMapper.updatePenalty(penalty);
    }

    /**
     * 批量删除罚款业务
     *
     * @param penaltyIds 需要删除的罚款业务主键
     * @return 结果
     */
    @Override
    public int deletePenaltyByPenaltyIds(Long[] penaltyIds) {
        return penaltyMapper.deletePenaltyByPenaltyIds(penaltyIds);
    }

    /**
     * 删除罚款业务信息
     *
     * @param penaltyId 罚款业务主键
     * @return 结果
     */
    @Override
    public int deletePenaltyByPenaltyId(Long penaltyId) {
        return penaltyMapper.deletePenaltyByPenaltyId(penaltyId);
    }
}
